package com.snj.test;

public class Main {
    public static void main(String[] args) {
        String input1 = "5（2异地）";
        String input2 = "11";
        String input3 = "10(2异地)";

        System.out.println(extractNumber(input1)); // 输出: 112
        System.out.println(extractNumber(input2)); // 输出: 11
        System.out.println(extractNumber(input3)); // 输出: 112
    }

    public static String extractNumber(String input) {
        StringBuilder numberPart = new StringBuilder();

        // 遍历字符串，提取数字部分，直到遇到括号或其他非数字字符
        for (int i = 0; i < input.length(); i++) {
            char c = input.charAt(i);
            if (Character.isDigit(c)) {
                numberPart.append(c);
            } else if (c == '（' || c == '(') {
                // 遇到左括号时停止提取
                break;
            }
        }

        return numberPart.toString();
    }
}